﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;

/* Generated  */
namespace EDMXParserV1
{
        [Serializable]
    public class Schema
    {
        public Schema()
        {
            EntityTypes = new List<EntityType>();
            Associations = new List<Association>();
            Functions = new List<Function>();
            ComplexTypes = new List<ComplexType>();
        }
        public String Namespace { get; set; }
        public String Alias { get; set; }
        public String Provider { get; set; }
        public String ProviderManifestToken { get; set; }
        public String XmlnsAnnotation { get; set; }
        public String XmlnsStore { get; set; }
        public String Xmlns { get; set; }
        public String p1UseStrongSpatialTypes { get; set; }
        public String xmlnsp1 { get; set; }

        public EntityContainer EntityContainer { get; set; }

        public List<EntityType> EntityTypes { get; set; }
        public List<Association> Associations { get; set; }
        public List<Function> Functions { get; set; }
        public List<ComplexType> ComplexTypes { get; set; }

        public static Schema New(XmlNode Node)
        {
            Schema Schema = new Schema();

            foreach (XmlAttribute Attribute in Node.Attributes)
            {
                switch (Attribute.Name)
                {
                    case "Namespace":
                        Schema.Namespace = Attribute.Value;
                        break;
                    case "Alias":
                        Schema.Alias = Attribute.Value;
                        break;
                    case "Provider":
                        Schema.Provider = Attribute.Value;
                        break;
                    case "ProviderManifestToken":
                        Schema.ProviderManifestToken = Attribute.Value;
                        break;
                    case "xmlns:store":
                        Schema.XmlnsStore = Attribute.Value;
                        break;
                    case "xmlns":
                        Schema.Xmlns = Attribute.Value;
                        break;
                    case "p1:UseStrongSpatialTypes":
                        Schema.p1UseStrongSpatialTypes = Attribute.Value;
                        break;
                    case "xmlns:annotation":
                        Schema.XmlnsAnnotation = Attribute.Value;
                        break;
                    case "xmlns:p1":
                        Schema.xmlnsp1 = Attribute.Value;
                        break;
                    default:
                        Globals.AttributeSwitchCoder(Attribute);
                        break;
                }
            }

            foreach (XmlNode ChildNode in Node.ChildNodes)
            {
                switch (ChildNode.Name)
                {
                    case "EntityContainer":
                        Schema.EntityContainer = EntityContainer.New(ChildNode);
                        break;
                    case "EntityType":
                        EntityType EntityType = EntityType.New( ChildNode);
                        Schema.EntityTypes.Add(EntityType);
                        break;
                    case "#comment":
                        break;
                    case "Association":
                        Association Association = Association.New( ChildNode);
                        Schema.Associations.Add(Association);
                        break;
                    case "Function":
                        Function Function = Function.New( ChildNode);
                        Schema.Functions.Add(Function);
                        break;
                    case "ComplexType":
                        ComplexType ComplexType = ComplexType.New(ChildNode);
                        Schema.ComplexTypes.Add(ComplexType);
                        break;
                    default:
                        Globals.NodeSwitchCoder(ChildNode);
                        break;
                }
            }

            return Schema;
        }
    }
}
